#include "composite.h"

#include <iostream>

using namespace std;

int main()
{
	Equipment* pComputer	= new Computer("Computer", 0);

	Equipment* pMonitor		= new Monitor("Monitor", 1000);
	Equipment* pChassis		= new Chassis("Chassis", 300);
	Equipment* pMB			= new MotherBoard("MotherBoard", 800);
	Equipment* pCPU			= new CPU("CPU", 700);
	Equipment* pAudioCard	= new AudioCard("AudioCard", 200);

	pComputer->add(pMonitor);
	pComputer->add(pChassis);

	pChassis->add(pMB);

	pMB->add(pCPU);
	pMB->add(pAudioCard);

	pComputer->show();

	cout<<"Total price of computer: ";
	cout<<pComputer->price()<<endl;

	// delete root item
	// it would delete all the sub object recursively
	delete pComputer, pComputer = NULL;
	
	return 0;
}
